package com.schpro.webexperiment.control;

import com.schpro.webexperiment.model.BaseModel;
import com.schpro.webexperiment.model.Result;
import com.schpro.webexperiment.service.CommonService;
import com.schpro.webexperiment.util.ResultUtils;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * TODO
 *
 * @author lss
 * @date 2019-02-27, Wed
 */
@RestController
@RequestMapping("/api/common")
public class CommonController {

  @Autowired
  private CommonService commonService;

  @RequestMapping("/getTree")
  public Result getTreeData() {
    List<BaseModel> tree = commonService.getTree();
    if (tree == null) {
      return ResultUtils.newFailedResult("数据异常");
    }
    return ResultUtils.newSuccessfulResult(tree);
  }
}
